1. Field of the Invention
The invention relates to a network system, and more particularly, to an apparatus and method for improving the management of received data packets.
2. Description of the Prior Art
A network device (e.g., network interfaced card, NIC) receives data packets from a network and transmits data packets from a host system. When a NIC receives a data packet from the network, the NIC will transfer the data packet into a data buffer located in the host system. The host system has a plurality of data buffers with some data buffers being in a “free” state (able to store data packet) and some data buffers being in an “unavailable” state (unable to store data packet). In order to locate a free data buffer, the NIC refers to descriptors. Descriptors are memory structures, which can be located either on the NIC or the host system, that correspond to a data buffer in the host system; a descriptor contains an own bit and the address and buffer length of a data buffer in the host system. Generally, the number of descriptors is a subset of the number of data buffers in the host system. In other words, there are fewer descriptors than data buffers.
The descriptors fall into one of two classes: free descriptors and unavailable descriptors. The free descriptors have corresponding data buffers in a free state and the unavailable descriptors have corresponding data buffers in an unavailable state. By referring to a free descriptor, the NIC is able to transfer a data packet into data buffers in a free state. When a data packet is transferred into the data buffers, the NIC marks the own bit of the corresponding descriptor to unavailable. The own bit of an unavailable descriptor is only marked free by the host system when either the host system clears the data buffer corresponding to the host system or when the host system associates the descriptor with a different data buffer that is in a free state.
The NIC issues an event signal to the host system to indicate what kind of data packet will be transferred into the data buffers. Data packets fall into one of two classes—ok packets and error packets—so naturally the NIC has two signals to represent the packets—an ok signal and an error signal. For example, if the NIC issues an ok signal, then the host system will post the data packet to the protocol stack and associate the descriptor corresponding to the data buffer used to store the data packet with a different data buffer that is in a free state. If the NIC issues an error signal, then the host system will clear the data buffer used to receive the transferred data packet and renew the buffer length of the descriptor corresponding to the data buffer.
Every signal issued by the NIC is allowed to notify the host system. This, however, makes for inefficiency in the management of the data packets received by the host system. For a string of received ok packets, this is not inefficient because the host system needs to address an ok packet as soon as it is received. However, for a string of received error packets, this is highly inefficient because the host system does not need to address an error packet as soon as it is received. For example, if 4 error packets are received in a row, then host system will halt its operations and clear the data buffer 4 times.
A prior art solution counts the number of times an event occurs and notifies the host system via a signal when the number of times an event occurs has reached a certain value. In this way, the prior art solution is able to reduce the number of times the host system interrupts its operations and diverts its resources and power. In the prior art solution, if the number of events counted that triggers the coalesced signal is too high, there is a danger that all the descriptors will be unavailable. With no free descriptors, the NIC will have not be able to obtain the address of a data buffer in a free state in the host system, meaning that the host system will drop the incoming data packets.
Some may argue that prior art will always have free descriptors available so long the number of events counted that triggers the coalesced event is not set to the total number of descriptors. However, this is not true as an error packet that is received may actually occupy more than one data buffer, which means that more than once descriptor will be marked as unavailable. Each packet includes length information. When the length information of the error packet is erroneous, the length of the error packet may exceed the length of the data buffer. As a result, more than one data buffer from the host system is needed, which means more than one descriptor will be marked from free to unavailable.